package com.atguigu.gmall.juc.threadlocal;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author 陈昆昆
 * @version 1.0
 * @date 2020/5/31 2:36
 */
public class ThreadlocalTest01 {
    public static ExecutorService executorService = Executors.newFixedThreadPool(10);

    public static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd SS:HH:mm");

    public  String simpleDate(int sends){
        Date date = new Date(1000*sends);
        String format =null;
        synchronized (ThreadlocalTest01.class) {
            format = simpleDateFormat.format(date);
        }
        return format;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 1000; i++) {
             int finali = i;
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    String date = new ThreadlocalTest01().simpleDate(finali);
                    System.out.println(Thread.currentThread().getName() + "--->" + date);
                }

            });

        }
        executorService.shutdown();
    }
}
